package sg.edu.nus.iss.billing.model.account;

import java.util.Comparator;

import sg.edu.nus.iss.billing.BillingConstants.SearchSortBy;

/**
 * @author Yeo Hee Ling, Ananda, EngKhoon
 */
public class AccountSorter implements Comparator<Account> {
	
	private SearchSortBy sortBy;
	
	public AccountSorter(SearchSortBy sortBy) {
		this.sortBy = sortBy;
	}
	
	public int compare(Account account1, Account account2) {
		int res = 0;
		
		if(SearchSortBy.ACCOUNT_NO == sortBy)
			return (account1.getAccountNo().compareTo(account2.getAccountNo()));
		if(SearchSortBy.NAME == sortBy)
			return (account1.getCustomerName().compareTo(account2.getCustomerName()));
		if(SearchSortBy.NRIC == sortBy)
			return (account1.getCustomerNRIC().compareTo(account2.getCustomerNRIC()));
		
		return res;
	}

}
